package com.example.baseweb.repository;

import com.example.baseweb.entity.Category;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;
import java.util.List;

@Repository
public interface CategoryRepository extends JpaRepository<Category, Long> {
    
    // 查询所有分类，按排序权重排序
    @Query("SELECT c FROM Category c ORDER BY c.sortOrder ASC, c.id ASC")
    List<Category> findAllOrderBySortOrder();
    
    // 根据状态查询分类
    List<Category> findByStatus(Integer status);
} 